class TFCNProj extends TFProjectile;

var xEmitter FlareTrail;
var xEmitter SmokeTrail;
var xEmitter Trail;

simulated event PreBeginPlay()
{
    Super.PreBeginPlay();

    if( (Owner != None) && Owner.IsA( 'Pawn' ) )
        Instigator = Pawn( Owner );
}

simulated function PostBeginPlay()
{
	Super.PostBeginPlay();

    if ( Level.NetMode != NM_DedicatedServer )
	{
		FlareTrail = Spawn(class'ShockProjElec', self);
		Trail = Spawn(class'TaskForces.tfCNTrail', self);
		SmokeTrail = Spawn(class'TaskForces.tfCNTrailSmoke', self);
	}

	Velocity = Speed * Vector(Rotation); // starts off slower so combo can be done closer
}

simulated function Destroyed()
{
    if (FlareTrail != None)
    {
        FlareTrail.mRegen = false;
    }
    if (Trail != None)
    {
        Trail.mRegen = false;
    }
    if (SmokeTrail != None)
    {
        SmokeTrail.mRegen = false;
    }
	Super.Destroyed();
}

/*simulated function DestroyTrails()
{
    if (FlareTrail != None)
        FlareTrail.Destroy();
    if (Trail != None)
        Trail.Destroy();
}*/

simulated function ProcessTouch(Actor Other, Vector HitLocation)
{
	if (Other != instigator && (!Other.IsA('Projectile') || Other.bProjTarget) )
    {
		SpawnEffects(HitLocation, -1 * Normal(Velocity) );
		Explode(HitLocation,Normal(HitLocation-Other.Location));
		Destroy();
	}
}

simulated function SpawnEffects( vector HitLocation, vector HitNormal )
{
	PlaySound(sound'TFMedia.CNImpact',SLOT_None,2,false,TransientSoundRadius);
    PlaySound(sound'TFMedia.CNDistantImpact',SLOT_None,1,false,TransientSoundRadius*5);

	if ( EffectIsRelevant(Location,false) )
	{
	   Spawn(class'ShockComboVortex');
   	   Spawn(class'TaskForces.TFCNExpSparks');
   	   Spawn(class'TaskForces.TFCNExpFlash');
   	   Spawn(class'TaskForces.TFCNExpSmoke');

       if (Level.NetMode != NM_DedicatedServer)
           Spawn(class'Taskforces.TFCNImpactGlow',self,,Location, rotator(-HitNormal));
	}
}

simulated function Landed( vector HitNormal )
{
    Velocity*=0;
}

simulated function HitWall (vector HitNormal, actor Wall)
{
	SpawnEffects(Location, -1 * Normal(Velocity) );
	Explode(Location,HitNormal);
	Destroy();
}

function BlowUp(vector HitLocation)
{
	HurtRadius(50+(50-lifespan)*35, DamageRadius+(50-lifespan)*10, MyDamageType, MomentumTransfer, HitLocation );
	MakeNoise(1.0);
}

simulated function Explode(vector HitLocation, vector HitNormal)
{
	local vector start;

	start = Location + 10 * HitNormal;
	BlowUp(start);

    Destroy();
}

defaultproperties
{
     Speed=1750.000000
     MaxSpeed=1750.000000
     bSwitchToZeroCollision=True
     Damage=50.000000
     DamageRadius=350.000000
     MomentumTransfer=50000.000000
     MyDamageType=Class'taskforces.DamTypeCNExp'
     ImpactSound=Sound'WeaponSounds.ShockRifle.ShockRifleExplosion'
     LightType=LT_Steady
     LightEffect=LE_QuadraticNonIncidence
     LightHue=150
     LightSaturation=222
     LightBrightness=255.000000
     LightRadius=6.000000
     DrawType=DT_StaticMesh
     StaticMesh=StaticMesh'WeaponStaticMesh.LinkProjectile'
     bDynamicLight=True
     bNetTemporary=False
     AmbientSound=Sound'WeaponSounds.ShockRifle.ShockRifleProjectile'
     LifeSpan=50.000000
     DrawScale=5.500000
     PrePivot=(X=20.000000)
     Skins(0)=FinalBlend'TFMedia.GenFX.tfGenSwirlTexBlu'
     Style=STY_Translucent
     SoundVolume=255
     SoundPitch=48
     SoundRadius=128.000000
     TransientSoundRadius=500.000000
     CollisionRadius=10.000000
     CollisionHeight=10.000000
     bProjTarget=True
     bFixedRotationDir=True
     RotationRate=(Roll=-100000)
     ForceType=FT_Constant
     ForceRadius=40.000000
     ForceScale=10.000000
}
